<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3.删除DOM节点</title>



</head>

<body>

<div id="father">
    <h1>标题一</h1>
    <p id="p1">p1</p>
    <p class="p2">p2</p>
    <p id="to-be-removed">凯德六号</p>
</div>

<script>

    // 对应 css 选择器
    var h1 = document.getElementsByTagName('h1');
    var p1 = document.getElementById('p1');
    var p2 = document.getElementsByClassName('p2');
    var father = document.getElementById('father');

    var children = father.children; // 获取父节点下的所有子节点

    // father.firstChild
    // father.lastChild

    // 拿到待删除节点:
    var self = document.getElementById('to-be-removed');
    // 拿到父节点:
    var parentElement = self.parentElement;
    // 删除:
    var removeChild = parentElement.removeChild(self);

//    removed === self; // true
    console.log((removeChild === self));

</script>

</body>
</html>